package com.blogs.ui;


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import com.blogs.component.BaseActivity;
import com.blogs.entity.AppConfig;
import com.blogs.service.SendErrorMsg;
import com.cnblogs.R;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

public class SplashActivity extends BaseActivity{
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        String path = "/sdcard/"+AppConfig.SD_CARD_FOLDER+"/";
        String logName=AppConfig.ERROR_LOG_NAME;
        File f=new File(path+logName);
        if(f.exists())
        {
        	String log_text="";
        	final File ff=f; 
        	try {
				FileReader read = new FileReader(path + logName);
				BufferedReader br = new BufferedReader(read);
				String row;
				while ((row = br.readLine()) != null) {
					log_text+=row+"\n";
				}
				new SendErrorMsg(log_text,new SendErrorMsg.IMsgCallBack() {
					
					public void onSuccess() {
						// TODO Auto-generated method stub
						
						ff.delete();
					}
					
					public void onFailed() {
						// TODO Auto-generated method stub
						
					}
				}).Send();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        	Log.i("log_text", log_text);
        }
        Message msg=new Message();
        msg.what=0;
        splashHandler.sendMessageDelayed(msg, 2000);
    }
    private Handler splashHandler=new Handler(){
    	public void dispatchMessage(android.os.Message msg) {
    		   Intent intent=new Intent();
    	       intent.setClass(SplashActivity.this, MainTabActivity.class);
    	       startActivity(intent);
    	       finish();
    	};
    };
}
